package com.changhongit.controller;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.changhongit.entity.Assess;
import com.changhongit.entity.MemberInfo;
import com.changhongit.entity.Order;
import com.changhongit.entity.OrderLogs;
import com.changhongit.entity.Resources;
import com.changhongit.entity.ServiceProject;
import com.changhongit.entity.ServiceProvider;
import com.changhongit.entity.ServiceType;
import com.changhongit.entity.ServiceUser;
import com.changhongit.entity.User;
import com.changhongit.returnentity.ReturnOrder;
import com.changhongit.service.AssessService;
import com.changhongit.service.MemberInfoService;
import com.changhongit.service.OrderLogsService;
import com.changhongit.service.OrderService;
import com.changhongit.service.ResourcesService;
import com.changhongit.service.ServiceProjectService;
import com.changhongit.service.ServiceProviderService;
import com.changhongit.service.ServiceTypeService;
import com.changhongit.service.ServiceUserService;
import com.changhongit.util.Common;
import com.changhongit.util.PageView;

/**
 * 
 * @author tp 2013-11-19
 * @version 1.0v
 */
@Controller
@RequestMapping(value = "/background/order/")
public class OrderController {

	@Autowired
	private OrderService orderService;

	@Autowired
	private ResourcesService resourcesService;

	@Autowired
	private ServiceProviderService serviceProviderService;

	@Autowired
	private MemberInfoService memberInfoService;

	@Autowired
	private OrderLogsService orderLogsService;

	@Autowired
	private ServiceUserService serviceUserService;

	@Autowired
	private AssessService assessService;

	@Autowired
	private ServiceProjectService serviceProjectService;
	
	@Autowired
	private ServiceTypeService serviceTypeService;

	/**
	 * 跳到用户查询页面
	 * 
	 * @return
	 */
	@RequestMapping(value = "userQuery")
	public String userQuery(Model model) {
		List<ServiceType> serviceTypes = serviceTypeService.findByPid(0);
		model.addAttribute("serviceTypes", serviceTypes);
		return "/background/order/userQuery";
	}

	/**
	 * 跳到新增页面
	 * 
	 * @return
	 */
	@RequestMapping(value = "addUI")
	public String addUI(Model model, Order order) {
		ServiceProvider serviceProvider = serviceProviderService.getById(String
				.valueOf(order.getServiceId()));
		List<ServiceProject> serviceProjects = serviceProjectService
				.findAllByServiceId(order.getServiceId());
		model.addAttribute("serviceProvider", serviceProvider);
		model.addAttribute("serviceProjects", serviceProjects);
		model.addAttribute("order", order);
		this.permissio(model);
		return "/background/order/add";
	}

	/**
	 * 权限树
	 * 
	 * @return
	 */
	@RequestMapping(value = "permissio")
	public String permissio(Model model) {
		List<Resources> allRes = resourcesService.findAll();
		StringBuffer sb = new StringBuffer();
		sb.append("var data = [];");
		for (Resources r : allRes) {
			sb.append("data.push({ fid: '" + r.getId() + "', pfid: '"
					+ r.getParentId() + "', fname: '" + r.getName() + "'});");

		}
		model.addAttribute("resources", sb);
		return "/background/resources/permissioUser";
	}

	/**
	 * 保存新增
	 * 
	 * @param model
	 * @param role
	 * @return
	 */
	@RequestMapping(value = "add")
	public String add(Model model, Order order, HttpServletRequest request) {
		Date date = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
		String orderno = sdf.format(date);
		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		order.setOrderTime(sdf1.format(date));
		int len = String.valueOf(orderService.findCountOrder()).trim().length();
		String orderNo = null;
		if (len == 1) {
			orderNo = orderno + "00" + orderService.findCountOrder();
		} else if (len == 2) {
			orderNo = orderno + "0" + orderService.findCountOrder();
		} else if (len > 2) {
			orderNo = orderno + orderService.findCountOrder();
		}
		order.setOrderNo(orderNo);
		User user = (User) request.getSession().getAttribute("userSession");
		order.setCallName(user.getUserName());
		order.setOrderStatus("A");
		order.setOrderflag(2);
		orderService.add(order);
		OrderLogs orderLogs = new OrderLogs();
		orderLogs.setTime(sdf1.format(date));
		orderLogs.setNotes(order.getServiceNotes());
		orderLogs.setOrderstatus(order.getOrderStatus());
		StringBuffer sb = new StringBuffer();
		sb.append(order.getOrderTime());
		sb.append(" 提交服务订单，");
		sb.append(order.getServiceTime());
		sb.append("去");
		sb.append(order.getServiceProjectName());
		sb.append(",呼叫中心：");
		sb.append(order.getCallName());
		orderLogs.setDescription(sb.toString());
		orderLogs.setOrderId(order.getId());
		orderLogsService.add(orderLogs);
		return "redirect:query.html";
	}

	/**
	 * 分页查询
	 * 
	 * @param model
	 * @param role
	 * @param pageNow
	 * @return
	 */
	@RequestMapping(value = "query")
	public String query(Model model, ReturnOrder order, String pageNow,
			HttpServletRequest request) {
		User user = (User) request.getSession().getAttribute("userSession");
		String loginType = (String) request.getSession().getAttribute(
				"loginType");
		if (loginType.equals("serviceProvider")) {
			ServiceProvider serviceProvider = serviceProviderService
					.findOneServiceProvider(user.getUserName());
			order.setServiceId(serviceProvider.getId());
		}
		PageView pageView = null;
		if (Common.isEmpty(pageNow)) {
			pageView = new PageView(1);
		} else {
			pageView = new PageView(Integer.parseInt(pageNow));
		}
		pageView = orderService.query(pageView, order);
		model.addAttribute("pageView", pageView);
		model.addAttribute("order", order);
		return "/background/order/list";
	}

	/**
	 * count分页查询
	 * 
	 * @param model
	 * @param role
	 * @param pageNow
	 * @return
	 */
	@RequestMapping(value = "count")
	public String countList(Model model, ReturnOrder order, String pageNow,
			HttpServletRequest request) {
		User user = (User) request.getSession().getAttribute("userSession");
		String loginType = (String) request.getSession().getAttribute(
				"loginType");
		if (loginType.equals("serviceProvider")) {
			ServiceProvider serviceProvider = serviceProviderService
					.findOneServiceProvider(user.getUserName());
			order.setServiceId(serviceProvider.getId());
		}
		PageView pageView = null;
		if (Common.isEmpty(pageNow)) {
			pageView = new PageView(1);
		} else {
			pageView = new PageView(Integer.parseInt(pageNow));
		}
		pageView = orderService.query(pageView, order);
		model.addAttribute("pageView", pageView);
		return "/background/order/count";
	}

	/**
	 * 查询单条记录
	 * 
	 * @param model
	 * @param roleId
	 * @param type
	 * @return
	 */
	@RequestMapping(value = "getById")
	public String getById(Model model, String id, int typeKey) {
		Order order = orderService.getById(id);
		Order orderOne = new Order();
		orderOne.setId(order.getId());
		orderOne.setOrderflag(1);
		orderService.modify(orderOne);
		ServiceProvider serviceProvider = serviceProviderService.getById(String
				.valueOf(order.getServiceId()));
		MemberInfo memberInfo = BackgroundController.parseXml(order.getMemberId());
		ServiceUser serviceUser = serviceUserService.getById(String
				.valueOf(order.getServiceUserId()));
		List<OrderLogs> orderlogs = orderLogsService.findAllByOrderId(id);
		model.addAttribute("role", order);
		model.addAttribute("memberInfo", memberInfo);
		model.addAttribute("serviceUser", serviceUser);
		model.addAttribute("serviceProvider", serviceProvider);
		model.addAttribute("orderlogs", orderlogs);
		if (typeKey == 1) {
			return "/background/order/edit";
		} else {
			return "/background/order/show";
		}
	}

	/**
	 * 查询单条记录
	 * 
	 * @param model
	 * @param roleId
	 * @param type
	 * @return
	 */
	@RequestMapping(value = "updateByUser")
	public String updateByUser(Model model, String id) {
		Order order = orderService.getById(id);
		List<ServiceProject> serviceProjects = serviceProjectService
				.findAllByServiceId(order.getServiceId());
		model.addAttribute("serviceProjects", serviceProjects);
		model.addAttribute("role", order);
		return "/background/order/edit";
	}

	/**
	 * 更新修改的信息
	 * 
	 * @param model
	 * @param role
	 * @return
	 */
	@RequestMapping(value = "update/baskpoke")
	public String updatebaskpoke(Model model, Order order,
			HttpServletRequest request) {
		Order orderinfo = orderService.getById(String.valueOf(order.getId()));
		model.addAttribute("orderinfo", orderinfo);
		User user = (User) request.getSession().getAttribute("userSession");
		ServiceProvider serviceProvider = serviceProviderService
				.findOneServiceProvider(user.getUserName());
		List<ServiceUser> serviceusers = serviceUserService.findAll(String
				.valueOf(serviceProvider.getId()));
		model.addAttribute("serviceusers", serviceusers);
		return "/background/order/baskpoke";
	}

	/**
	 * 更新修改的信息
	 * 
	 * @param model
	 * @param role
	 * @return
	 */
	@RequestMapping(value = "update/callback")
	public String updatecallback(Model model, Order order,
			HttpServletRequest request) {
		Order orderinfo = orderService.getById(String.valueOf(order.getId()));
		model.addAttribute("orderinfo", orderinfo);
		return "/background/order/callback";
	}

	/**
	 * 更新修改的信息
	 * 
	 * @param model
	 * @param role
	 * @return
	 */
	@RequestMapping(value = "update/userremove")
	public String userremove(Model model, Order order,
			HttpServletRequest request) {
		Order orderinfo = orderService.getById(String.valueOf(order.getId()));
		model.addAttribute("orderinfo", orderinfo);
		return "/background/order/remove";
	}

	/**
	 * 更新修改的信息
	 * 
	 * @param model
	 * @param role
	 * @return
	 */
	@RequestMapping(value = "update/serviceremove")
	public String serviceremove(Model model, Order order,
			HttpServletRequest request) {
		Order orderinfo = orderService.getById(String.valueOf(order.getId()));
		model.addAttribute("orderinfo", orderinfo);
		return "/background/order/remove";
	}

	/**
	 * 更新修改的信息
	 * 
	 * @param model
	 * @param role
	 * @return
	 */
	@RequestMapping(value = "update/ok")
	public String updateok(Model model, Order order, HttpServletRequest request) {
		Order orderinfo = orderService.getById(String.valueOf(order.getId()));
		model.addAttribute("orderinfo", orderinfo);
		return "/background/order/ok";
	}

	/**
	 * 更新修改的信息
	 * 
	 * @param model
	 * @param role
	 * @return
	 */
	@RequestMapping(value = "baskpoke")
	public String baskpoke(Model model, Order order) {
		order.setOrderStatus("B");
		OrderLogs orderLogs = new OrderLogs();
		orderLogs.setNotes(order.getServiceNotes());
		orderLogs.setOrderstatus(order.getOrderStatus());
		order.setServiceNotes("");
		String price = order.getPrice();
		order.setPrice("");
		orderService.modify(order);
		Order orders = orderService.getById(String.valueOf(order.getId()));
		ServiceUser service = new ServiceUser();
		service.setId(orders.getServiceUserId());
		service.setStatues("Y");
		serviceUserService.updateServiceUserStatus(service);
		ServiceUser serviceUser = serviceUserService.getById(String
				.valueOf(orders.getServiceUserId()));
		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		StringBuffer sb = new StringBuffer(sdf1.format(new Date()));
		orderLogs.setTime(sdf1.format(new Date()));
		sb.append("已预约，");
		sb.append(order.getPlanTime());
		sb.append(",预计收费：" + price + "元,");
		sb.append("服务人员：" + serviceUser.getName() + "，联系电话："
				+ serviceUser.getMobilephone());
		orderLogs.setDescription(sb.toString());
		orderLogs.setOrderId(order.getId());
		orderLogsService.add(orderLogs);
		return "redirect:query.html";
	}

	/**
	 * 更新修改的信息
	 * 
	 * @param model
	 * @param role
	 * @return
	 */
	@RequestMapping(value = "ok")
	public String ok(Model model, Order order) {
		order.setOrderStatus("C");
		OrderLogs orderLogs = new OrderLogs();
		orderLogs.setNotes(order.getServiceNotes());
		orderLogs.setOrderstatus(order.getOrderStatus());
		order.setServiceNotes("");
		orderService.modify(order);
		Order orders = orderService.getById(String.valueOf(order.getId()));
		ServiceUser service = new ServiceUser();
		service.setId(orders.getServiceUserId());
		service.setStatues("N");
		serviceUserService.updateServiceUserStatus(service);
		ServiceUser serviceUser = serviceUserService.getById(String
				.valueOf(orders.getServiceUserId()));
		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		StringBuffer sb = new StringBuffer(sdf1.format(new Date()));
		orderLogs.setTime(sdf1.format(new Date()));
		sb.append("已完成，");
		sb.append(order.getFactTime());
		sb.append(",收费：" + order.getPrice() + "元,");
		sb.append("服务人员：" + serviceUser.getName() + "，联系电话："
				+ serviceUser.getMobilephone());
		orderLogs.setDescription(sb.toString());
		orderLogs.setOrderId(order.getId());
		orderLogsService.add(orderLogs);
		return "redirect:query.html";
	}

	/**
	 * 更新修改的信息
	 * 
	 * @param model
	 * @param role
	 * @return
	 */
	@RequestMapping(value = "remove")
	public String remove(Model model, Order orders, HttpServletRequest request) {
		Order order = orderService.getById(String.valueOf(orders.getId()));
		;
		User user = (User) request.getSession().getAttribute("userSession");
		String loginType = (String) request.getSession().getAttribute(
				"loginType");
		OrderLogs orderLogs = new OrderLogs();
		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		StringBuffer sb = new StringBuffer(sdf1.format(new Date()));
		orderLogs.setTime(sdf1.format(new Date()));
		if (loginType.equals("serviceProvider")) {
			order.setOrderStatus("F");
			sb.append("服务商取消，");
			sb.append(orders.getServiceNotes());
			orderLogs.setNotes(order.getServiceNotes());
			orderLogs.setOrderstatus(order.getOrderStatus());
			order.setServiceNotes("");
		}
		if (loginType.equals("callCenter")) {
			if ("B".equals(order.getOrderStatus())) {
				ServiceUser service = new ServiceUser();
				service.setId(order.getServiceUserId());
				service.setStatues("N");
				serviceUserService.updateServiceUserStatus(service);
			}
			order.setOrderStatus("E");
			sb.append("用户取消，");
			sb.append(orders.getServiceNotes());
			sb.append("呼叫中心：" + user.getUserName());
			orderLogs.setNotes(order.getServiceNotes());
			orderLogs.setOrderstatus(order.getOrderStatus());
			order.setServiceNotes("");
		}
		orderLogs.setDescription(sb.toString());
		orderLogs.setOrderId(order.getId());
		orderService.modify(order);
		orderLogsService.add(orderLogs);
		return "redirect:query.html";
	}

	/**
	 * 更新修改的信息
	 * 
	 * @param model
	 * @param role
	 * @return
	 */
	@RequestMapping(value = "callback")
	public String baskpoke(Model model, Assess assess,
			HttpServletRequest request) {
		Order order = new Order();
		order.setId(assess.getOrderId());
		order.setOrderStatus("D");
		OrderLogs orderLogs = new OrderLogs();
		orderService.modify(order);
		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		StringBuffer sb = new StringBuffer(sdf1.format(new Date()));
		orderLogs.setTime(sdf1.format(new Date()));
		assess.setTime(sdf1.format(new Date()));
		assessService.add(assess);
		sb.append("已回访，");
		sb.append(assess.getServiceattitude());
		sb.append("，评价：" + assess.getServicequality() + "颗星，");
		User user = (User) request.getSession().getAttribute("userSession");
		sb.append("呼叫中心：" + user.getUserName());
		orderLogs.setDescription(sb.toString());
		orderLogs.setOrderId(order.getId());
		orderLogs.setNotes(assess.getDescription());
		orderLogs.setOrderstatus(order.getOrderStatus());
		orderLogsService.add(orderLogs);
		return "redirect:query.html";
	}

	/**
	 * 更新修改的信息
	 * 
	 * @param model
	 * @param role
	 * @return
	 */
	@RequestMapping(value = "edit")
	public String edit(Model model, Order order, HttpServletRequest request) {
		order.setOrderStatus("A");
		OrderLogs orderLogs = new OrderLogs();
		orderLogs.setNotes(order.getServiceNotes());
		orderLogs.setOrderstatus(order.getOrderStatus());
		order.setServiceNotes("");
		orderService.modify(order);
		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		StringBuffer sb = new StringBuffer(sdf1.format(new Date()));
		orderLogs.setTime(sdf1.format(new Date()));
		sb.append("用户修改，");
		sb.append("服务时间：" + order.getServiceTime() + ",");
		sb.append("服务项目：" + order.getServiceProjectName() + ",");
		User user = (User) request.getSession().getAttribute("userSession");
		sb.append("呼叫中心：" + user.getUserName());
		orderLogs.setDescription(sb.toString());
		orderLogs.setOrderId(order.getId());
		orderLogsService.add(orderLogs);
		orderLogs.setOrderstatus(order.getOrderStatus());
		return "redirect:query.html";
	}

	/**
	 * 更新修改的信息
	 * 
	 * @param model
	 * @param role
	 * @return
	 */
	@RequestMapping(value = "serviceOrderNum")
	public String serviceOrderNum(Model model, String pageNow, ReturnOrder order) {
		PageView pageView = null;
		if (Common.isEmpty(pageNow)) {
			pageView = new PageView(1);
		} else {
			pageView = new PageView(Integer.parseInt(pageNow));
		}
		pageView = orderService.queryServiceOrderNum(pageView, order);
		model.addAttribute("pageView", pageView);
		return "/background/order/serviceordernum";
	}

	@RequestMapping(value = "/getServiceProjects")
	public void preCheckUserName(String id, HttpServletResponse response) {
		response.setContentType("text/html;charset=GBK");
		try {
			List<ServiceProject> serviceProjects = serviceProjectService
					.findAllByServiceId(Integer.valueOf(id));
			String context = null;
			for (int i = 0; i < serviceProjects.size(); i++) {
				ServiceProject serviceProject = serviceProjects.get(i);
				if (context == null) {
					context = "<div class=\"item\" id="
							+ serviceProject.getId()
							+ "><label class=\"titem\"><input  type=\"checkbox\" value="
							+ serviceProject.getId() + " class=\"b\" />"
							+ serviceProject.getName()
							+ "</label><div class=\"sitem\"></div></div>";
				} else {
					context = context
							+ "<div class=\"item\" id="
							+ serviceProject.getId()
							+ "><label class=\"titem\"><input  type=\"checkbox\" value="
							+ serviceProject.getId() + " class=\"b\" />"
							+ serviceProject.getName()
							+ "</label><div class=\"sitem\"></div></div>";
				}
			}
			response.getWriter().print(context);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 更新修改的信息
	 * 
	 * @param model
	 * @param role
	 * @return
	 */
	@RequestMapping(value = "serviceOrderNumYear")
	public String serviceOrderNumYear(Model model, String pageNow,
			ReturnOrder order, String year, String month, String day,
			String selectlabel) {
		PageView pageView = null;
		if (Common.isEmpty(pageNow)) {
			pageView = new PageView(1);
		} else {
			pageView = new PageView(Integer.parseInt(pageNow));
		}
		model.addAttribute("servicename", order.getServicename());
		if ("A".equals(selectlabel)) {
			order.setOrderTime(year);
			pageView = orderService.queryServiceOrderNumYMonth(pageView, order);
			model.addAttribute("pageView", pageView);
			model.addAttribute("selectlabel", selectlabel);
			model.addAttribute("year", year);
			return "/background/order/serviceordernumymonth";
		} else if ("B".equals(selectlabel)) {
			order.setOrderTime(month);
			order.setOrderStatus(selectlabel);
			pageView = orderService.queryServiceOrderNumMonth(pageView, order);
			model.addAttribute("pageView", pageView);
			model.addAttribute("selectlabel", selectlabel);
			model.addAttribute("month", month);
			model.addAttribute("day", day);
			return "/background/order/serviceordernummonth";
		} else if ("C".equals(selectlabel)) {
			order.setOrderTime(day);
			order.setOrderStatus(selectlabel);
			pageView = orderService.queryServiceOrderNumMonth(pageView, order);
			model.addAttribute("pageView", pageView);
			model.addAttribute("selectlabel", selectlabel);
			model.addAttribute("month", month);
			model.addAttribute("day", day);
			return "/background/order/serviceordernummonth";
		}

		pageView = orderService.queryServiceOrderNumYear(pageView, order);
		model.addAttribute("pageView", pageView);
		return "/background/order/serviceordernumyear";
	}

	/**
	 * 年收入统计
	 * 
	 * @param model
	 * @param pageNow
	 * @param order
	 * @return
	 */
	@RequestMapping(value = "revenueByYear")
	public String revenueByYear(Model model, String pageNow, ReturnOrder order,
			String year, String month, String day, String selectlabel) {
		PageView pageView = null;
		if (Common.isEmpty(pageNow)) {
			pageView = new PageView(1);
		} else {
			pageView = new PageView(Integer.parseInt(pageNow));
		}
		model.addAttribute("servicename", order.getServicename());
		if ("A".equals(selectlabel)) {
			order.setOrderTime(year);
			pageView = orderService.queryRevenueByYmonth(pageView, order);
			model.addAttribute("pageView", pageView);
			model.addAttribute("selectlabel", selectlabel);
			model.addAttribute("year", year);
			return "/background/order/revenuebyymonth";
		} else if ("B".equals(selectlabel)) {
			order.setOrderTime(month);
			order.setOrderStatus(selectlabel);
			pageView = orderService.queryRevenueByMonth(pageView, order);
			model.addAttribute("pageView", pageView);
			model.addAttribute("selectlabel", selectlabel);
			model.addAttribute("month", month);
			model.addAttribute("day", day);
			return "/background/order/revenuebymonth";
		} else if ("C".equals(selectlabel)) {
			order.setOrderTime(day);
			order.setOrderStatus(selectlabel);
			pageView = orderService.queryRevenueByMonth(pageView, order);
			model.addAttribute("pageView", pageView);
			model.addAttribute("selectlabel", selectlabel);
			model.addAttribute("month", month);
			model.addAttribute("day", day);
			return "/background/order/revenuebymonth";
		}
		pageView = orderService.queryRevenueByYear(pageView,order);
		model.addAttribute("pageView", pageView);
		return "/background/order/revenuebyyear";
	}

	/**
	 * 每个人收入
	 * 
	 * @param model
	 * @param pageNow
	 * @param order
	 * @return
	 */
	@RequestMapping(value = "serviceUserRevenueByYear")
	public String queryServiceUserRevenueByYear(Model model, String pageNow,
			ReturnOrder order, String year, String month, String day,
			String selectlabel) {
		PageView pageView = null;
		if (Common.isEmpty(pageNow)) {
			pageView = new PageView(1);
		} else {
			pageView = new PageView(Integer.parseInt(pageNow));
		}
		model.addAttribute("servicename", order.getServicename());
		if ("A".equals(selectlabel)) {
			order.setOrderTime(year);
			pageView = orderService.queryServiceUserRevenueByYMonth(pageView,
					order);
			model.addAttribute("pageView", pageView);
			model.addAttribute("year", year);
			return "/background/order/serviceUserRevenueByYmonth";
		} else if ("B".equals(selectlabel)) {
			order.setOrderTime(month);
			order.setOrderStatus(selectlabel);
			pageView = orderService.queryServiceUserRevenueByMonth(pageView,
					order);
			model.addAttribute("pageView", pageView);
			model.addAttribute("selectlabel", selectlabel);
			model.addAttribute("month", month);
			model.addAttribute("day", day);
			return "/background/order/serviceUserRevenueBymonth";
		} else if ("C".equals(selectlabel)) {
			order.setOrderTime(day);
			order.setOrderStatus(selectlabel);
			pageView = orderService.queryServiceUserRevenueByMonth(pageView,
					order);
			model.addAttribute("pageView", pageView);
			model.addAttribute("selectlabel", selectlabel);
			model.addAttribute("month", month);
			model.addAttribute("day", day);
			return "/background/order/serviceUserRevenueBymonth";
		}
		pageView = orderService.queryServiceUserRevenueByYear(pageView, order);
		model.addAttribute("pageView", pageView);
		return "/background/order/serviceUserRevenueByYear";
	}

}
